package com.uzai.console.service.feign.impl;

import com.uzai.common.result.ResponseCode;
import com.uzai.console.common.UzaiRespVo;
import com.uzai.console.dto.feign.alarm.AlarmMsgFeignDto;
import com.uzai.console.dto.feign.fdSendJob.FdSendJobIdFeignDto;
import com.uzai.console.dto.feign.groupsendjob.GroupSendChildidPushDto;
import com.uzai.console.dto.feign.groupsendjob.GroupSendJobIdFeignDto;
import com.uzai.console.dto.feign.groupsendjob.NewGroupSendMsgDto;
import com.uzai.console.dto.feign.pyq.DeletePyqDto;
import com.uzai.console.dto.feign.pyq.SendPyqDto;
import com.uzai.console.entity.es.EsFdGroupSendMsg;
import com.uzai.console.entity.es.PyqJobDetail;
import com.uzai.console.service.feign.UzaiBroadcastFeignService;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * @Auther: jianghan
 * @Date: 2021/11/24 16:24
 * @Description:
 */
@Component
public class UzaiBroadcastFeignFallbackFactory implements FallbackFactory<UzaiBroadcastFeignService> {

    private static Logger logger = LoggerFactory.getLogger(UzaiBroadcastFeignFallbackFactory.class);

    @Override
    public UzaiBroadcastFeignService create(Throwable throwable) {

        logger.error("--广播群发调用微服务出错，err:={}", throwable);

        return new UzaiBroadcastFeignService() {
            @Override
            public UzaiRespVo<Boolean> sendPyqById(SendPyqDto sendPyqDto) {
                UzaiRespVo<Boolean> uzaiRespVo= new UzaiRespVo<>();
                uzaiRespVo.setData(false);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }

            @Override
            public UzaiRespVo<Boolean> deletePyq(DeletePyqDto deletePyqDto) {
                UzaiRespVo<Boolean> uzaiRespVo= new UzaiRespVo<>();
                uzaiRespVo.setData(false);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }

            @Override
            public UzaiRespVo<Boolean> sysMsgPush(AlarmMsgFeignDto alarmMsgFeignDto) {
                UzaiRespVo<Boolean> uzaiRespVo= new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }

            @Override
            public UzaiRespVo<Boolean> pyqMsgPush(List<PyqJobDetail> pyqJobDetailList) {
                UzaiRespVo<Boolean> uzaiRespVo= new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }

            @Override
            public UzaiRespVo<Boolean> groupSendMsgPush(List<NewGroupSendMsgDto> newGroupSendMsgDtoList){
                UzaiRespVo<Boolean> uzaiRespVo= new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }

            @Override
            public UzaiRespVo<Boolean> groupSendChildIdPush(GroupSendChildidPushDto groupSendChildidPushDto){
                UzaiRespVo<Boolean> uzaiRespVo= new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }

//            @Override
//            public UzaiRespVo<Integer> groupSendFinishCount(@RequestBody GroupSendJobIdFeignDto groupSendJobIdFeignDto){
//                UzaiRespVo<Integer> uzaiRespVo= new UzaiRespVo<>();
//                uzaiRespVo.setData(null);
//                uzaiRespVo.setCode(ResponseCode.ERROR);
//                uzaiRespVo.setTime(System.currentTimeMillis());
//                uzaiRespVo.setMsg("调用失败");
//                return uzaiRespVo;
//            }

            @Override
            public UzaiRespVo<Integer> fdSendFinishCount(@RequestBody FdSendJobIdFeignDto fdSendJobIdFeignDto){
                UzaiRespVo<Integer> uzaiRespVo= new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }

            @Override
            public UzaiRespVo<Boolean> fdSendMsgPush(List<EsFdGroupSendMsg> esFdGroupSendMsgList){
                UzaiRespVo<Boolean> uzaiRespVo= new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }

            @Override
            public UzaiRespVo<Object> fdPushChildid(FdSendJobIdFeignDto fdSendJobIdFeignDto){
                UzaiRespVo<Object> uzaiRespVo= new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }

        };
    }

}
